package com.sheliduan.itlearning.admin.controller;

import com.sheliduan.itlearning.admin.model.vos.tag.AddTagReqVO;
import com.sheliduan.itlearning.admin.model.vos.tag.DeleteTagReqVO;
import com.sheliduan.itlearning.admin.model.vos.tag.FindTagPageListReqVO;
import com.sheliduan.itlearning.admin.model.vos.tag.UpdateTagReqVO;
import com.sheliduan.itlearning.admin.service.AdminTagService;
import com.sheliduan.itlearning.common.aspect.ApiOperationLog;
import com.sheliduan.itlearning.common.model.vos.IdReqVO;
import com.sheliduan.itlearning.common.utils.PageResponseData;
import com.sheliduan.itlearning.common.utils.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 断舍离
 * @date: 2025/2/18 8:30
 * @description: 后台管理员标签管理控制器
 **/
@RestController
@RequestMapping("/admin")
public class AdminTagController {

    @Autowired
    private AdminTagService adminTagService;

    @PostMapping("/tag/pageList")
    @ApiOperationLog(description = "标签分页数据获取")
    public PageResponseData findTagPageList(@RequestBody @Validated FindTagPageListReqVO findTagPageListReqVo){
        return adminTagService.findTagPageList(findTagPageListReqVo);
    }

    @PostMapping("/tag/add")
    @ApiOperationLog(description = "添加标签")
    public ResponseData addTag(@RequestBody @Validated AddTagReqVO addTagReqVo){
        return adminTagService.addTag(addTagReqVo);
    }

    @PostMapping("/tag/delete")
    @ApiOperationLog(description = "删除标签")
    public ResponseData deleteTag(@RequestBody @Validated DeleteTagReqVO deleteTagReqVo){
        return adminTagService.deleteTag(deleteTagReqVo);
    }

    @PostMapping("/tag/update")
    @ApiOperationLog(description = "修改标签")
    public ResponseData updateTag(@RequestBody @Validated UpdateTagReqVO updateTagReqVO){
        return adminTagService.updateTag(updateTagReqVO);
    }

    /*
     * 根据id查找用户
     * */
    @PostMapping("/tag/selectById")
    @ApiOperationLog(description = "根据id查找标签")
    public ResponseData selectById(@RequestBody @Validated IdReqVO idReqVO) {
        return adminTagService.selectById(idReqVO.getId());
    }
}
